﻿using System.Reflection;

namespace AbstractFactory
{
    internal abstract class Factory
    {
        public static Factory GetFactory(string className)
        {
            try
            {
                var assembly = Assembly.GetExecutingAssembly();
                return (Factory)assembly.CreateInstance(className);
            }
            catch (Exception e)
            {
                Console.WriteLine($"没有找对{className}类。");
                Console.WriteLine(e.StackTrace);
                return null;
            }
        }

        public abstract Link CreateLink(string caption, string url);
        public abstract Tray CreateTray(string caption);
        public abstract Page CreatePage(string title, string author);
    }
}
